<include file="Public/header"/>
    <div class="row">
        <div class="layui-tab">
            <ul class="layui-tab-title">
                <li class="" data-url="<{:U('User/usermoney',['userid'=>$info[id]])}>" onclick="load_url(this)">今日明细</li>
                <li class="" data-url="<{:U('User/incrMoney',['uid'=>$info[id]])}>" onclick="load_url(this)">加/减余额</li>
                <li class="<if condition="$_GET['tradeType']=='t1'">layui-this</if>" data-url="<{:U('User/frozenTiming',['uid'=>$info[id],'tradeType'=>'t1'])}>" onclick="load_url(this)">T1资金解冻</li>
                <li class="<if condition="$_GET['tradeType']=='d1'">layui-this</if>" data-url="<{:U('User/frozenTiming',['uid'=>$info[id],'tradeType'=>'d1'])}>" onclick="load_url(this)">D1资金解冻</li>
                <li class="" data-url="<{:U('User/frozenMoney',['uid'=>$info[id]])}>" onclick="load_url(this)">解冻金额</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <form class="layui-form" action="" method="get" autocomplete="off" id="orderform">
                        <input type="hidden" name="m" value="<{$model}>">
                        <input type="hidden" name="c" value="Order">
                        <input type="hidden" name="a" value="changeRecord">
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <input type="text" name="orderid" autocomplete="off" placeholder="请输入订单号"
                                       class="layui-input" value="<{$_GET['orderid']}>">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="createtime" id="createtime"
                                       placeholder="起始时间" value="<{$_GET['createtime']|urldecode}>">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <button type="submit" class="layui-btn layui-bg-blue"><i class="fa fa-search"></i> 搜索</button>
                            </div>
                        </div>
                    </form>
                    <div class="layui-btn-group demoTable" style="margin-top:10px;">
                        <button class="layui-btn layui-bg-blue" data-type="getCheckData">批量解冻</button>
                    </div>
                    <table class="layui-table" lay-data="{width:'100%',id:'frozonData'}">
                        <thead>
                        <tr>
                            <th lay-data="{checkbox:true, fixed: true,field:'key'}">
                                选择
                            </th>
                            <th lay-data="{field:'id',width:60}">ID</th>
                            <th lay-data="{field:'orderid', width:240}">订单号</th>
                            <th lay-data="{field:'amount', width:100}">冻结金额</th>
                            <!--<th lay-data="{field:'tongdao', width:200}">通道</th>-->
                            <th lay-data="{field:'createtime', width:180}">添加时间</th>
                            <th lay-data="{field:'status', width:120}">状态</th>
                            <th lay-data="{field:'handle',width:100,fixed: 'right'}" lay-filter="contentstr">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <volist name="list" id="vo">
                            <tr>
                                <td></td>
                                <td><{$vo.id}></td>
                                <td style="text-align:center;"><{$vo.orderid}></td>
                                <td style="text-align:center;"><{$vo.money}></td>
                                <!--<td style="text-align:center;"><{$vo["pid"]|getProduct}></td>-->
                                <td style="text-align:center;"><{$vo.addtime|date='Y-m-d H:i:s',###}></td>
                                <td style="text-align:center;">
                                    <if condition="$vo.status == 1">
                                        冻结中
                                        <else/>
                                        已解冻
                                    </if>
                                </td>
                                <td>
                                    <if condition="$vo.status == 1">
                                        <button class="layui-btn layui-btn-small layui-btn-danger" onclick="frozen(this,'<{$vo.id}>','<{$_GET["tradeType"]}>')"
                                        >解冻</button>
                                        <else/>

                                    </if>

                                </td>
                            </tr>
                        </volist>
                        </tbody>
                    </table>
                    <!--交易列表-->
                    <div class="pagex"> <{$page}></div>
            </div>
            </div>
        </div>
    </div>
<include file="Public/footer"/>
<script>
    layui.use(['laydate', 'laypage', 'layer', 'table',['form']], function() {
        var laydate = layui.laydate //日期
            , laypage = layui.laypage //分页
            ,layer = layui.layer //弹层
            ,form = layui.form //表单
            , table = layui.table; //表格
        //日期时间范围
        laydate.render({
            elem: '#createtime'
            , type: 'datetime'
            ,theme: 'molv'
            , range: '|'
        });
        var $ = layui.$, active = {
            getCheckData: function(){ //获取选中数据
                var checkStatus = table.checkStatus('frozonData')
                    ,data = checkStatus.data;
                var msg="";
                var iscontinute=true;
                if(!(data&&data.length>0)){
                    layer.alert("请选择需要解冻的数据");
                    return;
                }
                var ids="";
                var amount=0;
                for(var i=0;i<data.length;i++) {
                    ids += (i>0?",":"")+data[i]["id"];
                    amount =  (Number(amount)+Number(data[i]["amount"])).toFixed(2);
                }
                console.log(amount);
                layer.confirm('批量解冻金额'+amount, function (index) {
                    $.ajax({
                        url :"<{:U('User/frozenHandles')}>",
                        data:{ids:ids,type:"<{$_GET['tradeType']}>"},
                        type : "POST",
                        dataType : 'json',
                        success : function (result){
                            if(result.status == 0){
                                layer.alert("解冻成功！",function () {
                                    location.replace(location.href);
                                });
                            }else if(result.count>0){
                                layer.alert("成功解冻"+result.count+"条数据，原因："+result.msg,function () {
                                    location.replace(location.href);
                                });
                            }else{
                                layer.alert("解冻失败",function () {
                                    location.replace(location.href);
                                });
                            }
                        }
                    });
                });
                


                
            }

        };
        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });


    /*解冻*/
    function frozen(obj, id, type) {
        layer.confirm('确认要解冻吗？', function (index) {
            $.ajax({
                url:"<{:U('User/frozenHandle')}>",
                type:'post',
                data:{id:id,type:type},
                success:function(res){
                    if(res.status == 0){
                        layer.msg('已解冻!',{icon:-1,time:1000},function(){
                            location.replace(location.href);

                        });
                    }
                }
            });
        });
    }
    function load_url(url) {
        var url = $(url).data('url');
        location.href = url;
    }

</script>
</body>
</html>